package DynamicProgramming;
/*
 * 一和零
 */
public class lc474 {

    public int findMaxForm(String[] strs, int m, int n) {
        int[][] dp = new int[m + 1][n + 1];
        dp[0][0] = 0;
        for (String str: strs) {
            int x = 0, y = 0;
            x = (int)str.chars().filter(c -> c == '0').count();
            y = (int)str.chars().filter(c -> c == '1').count();
            for (int i = m; i >= x; i--) {
                for (int j = n; j >= y; j--) {
                    dp[i][j] = Math.max(dp[i][j], dp[i - x][j - y] + 1);
                }
            }
        }
        return dp[m][n];
    }

}
